package com.southwind.springboottest.studykotlin.s2

import com.southwind.springboottest.studykotlin.s1.age
import com.southwind.springboottest.studykotlin.s2.KtBase29.webServiceloginAPI
import java.lang.Exception


//TODO 45.Kotlin语言的replace完成加密解码操作
fun main() {
    val sourcePwd = "ABCDEFGHIIKLMNOPQRSTUVWXYZ"
    println("原始密码是：$sourcePwd")
    //加密方式就是把字符替换成了数字，打乱了，就属于加密了
    val newPwd = sourcePwd.replace(Regex("[AKMNO]")){
//        it.value
        when(it.value){
            "A" -> "9"
            "K" -> "3"
            "M" -> "5"
            "N" -> "1"
            "O" -> "4"
            else -> it.value;
        }
    }
    println("加密后的密码是：$newPwd")
    val sourcePwdnew = newPwd.replace(Regex("[93514]")){
        when(it.value){
            "9" -> "A"
            "3" -> "K"
            "5" -> "M"
            "1" -> "N"
            "4" -> "O"
            else -> it.value
        }
    }
    println("解密后的密码是：$sourcePwdnew")
}
